import sqlite3


def getDB():
    conn = sqlite3.connect("todb_db.db")
    return conn


def checkTableExits():
    conn = getDB()
    cursor = conn.cursor()
    sql = 'select count(*) from sqlite_master where type="table" and name="todo_table"'
    cursor.execute(sql)
    result = cursor.fetchone()
    res = True
    if result[0] == 0:
        res = False
    cursor.close()
    conn.close()
    return res


def createTable():
    conn = getDB()
    cursor = conn.cursor()
    cursor.execute('''
        CREATE TABLE todo_table (
        id text,
        date text,
        content text,
        complete int
        )
        ''')
    conn.commit()
    cursor.close()
    conn.close()


if __name__ == '__main__':
    checkTableExits()
    createTable()
